package day01.cn.itcast.reflect;

import day01.cn.itcast.doMain.Person;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

/**
 * @author Lenovo
 */
public class ReflectDemo3 {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, InstantiationException {
        Class personClass=Person.class;
        Constructor constructor =personClass.getConstructor(String.class,int.class);
        System.out.println(constructor);
        Object person=constructor.newInstance("张三",23);
        System.out.println(person);
        System.out.println("---------");
        Constructor constructor1 =personClass.getConstructor();
        System.out.println(constructor1);
        Object person1=constructor.newInstance("张三",23);
        System.out.println(person1);

        Object o=personClass.newInstance();
        System.out.println(o);

    }

}
